package com.sfh.cp.home;

import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.view.View;

import com.sfh.cp.R;
import com.sfh.cp.base.AbstractBaseFragment;
import com.sfh.cp.home.child.CityWideFragment;
import com.sfh.cp.home.child.GroomFragment;
import com.sfh.cp.home.child.NewestFragment;
import com.sfh.cp.home.child.RankingFragment;
import com.sfh.lib.mvp.IPresenter;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2018/3/7.
 */

public class HomeFragment extends AbstractBaseFragment {

    public static HomeFragment newFragment(){
        return new HomeFragment();
    }

    @BindView(R.id.tab_layout)
    TabLayout tabLayout;
    @BindView(R.id.view_pager)
    ViewPager viewPager;

    HomePageAdapter pageAdapter;

    @Override
    public int getLayout() {
        return R.layout.home_fragment;
    }

    @Override
    public void initData(View view) {
        ButterKnife.bind(this, view);
        this.init();
    }

    private void init(){
        tabLayout.setupWithViewPager(viewPager);

        pageAdapter = new HomePageAdapter(getChildFragmentManager());
        //推荐
        pageAdapter.setFragmentList(new HomeMenuData(GroomFragment.newFragment(), "推荐"));
        // 最新
        pageAdapter.setFragmentList(new HomeMenuData(NewestFragment.newFragment(),"最新"));
        // 话题
      //  pageAdapter.setFragmentList(new HomeMenuData(TopicFragment.newFragment(),"话题"));
        // 榜单
        pageAdapter.setFragmentList(new HomeMenuData(RankingFragment.newFragment(),"榜单"));
        // 同城
        pageAdapter.setFragmentList(new HomeMenuData(CityWideFragment.newFragment(),"同城"));
        viewPager.setAdapter(pageAdapter);
        viewPager.setOffscreenPageLimit(1);
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
    }

    @Override
    public IPresenter getPresenter() {
        return null;
    }
}
